#ifndef SCANNER_H
#define SCANNER_H

	#include "globaldefs.h"
	
	#define IS_NULL(c)			(c == 0)
	#define IS_US(c)			(c == '_')
	#define IS_NUMBER(c)		(c >= '0' && c <= '9')
	#define IS_ULETTER(c)		(c >= 'A' && c <= 'Z')
	#define IS_ULETTER_(c)		(c >= 'A' && c <= 'Z' || IS_US(c))
	#define IS_LLETTER(c)		(c >= 'a' && c <= 'z')
	#define IS_LLETTER_(c)		(c >= 'a' && c <= 'z' || IS_US(c))
	#define IS_LETTER(c)		(IS_LLETTER(c) || IS_ULETTER(c))
	#define IS_LETTER_(c)		(IS_LLETTER(c) || IS_ULETTER(c) || IS_US(c))
	#define IS_LET_OR_NUM(c)	(IS_LETTER(c) || IS_NUMBER(c))
	#define IS_LET_OR_NUM_(c)	(IS_LETTER(c) || IS_NUMBER(c) || IS_US(c))
	#define IS_BINARY(c)		(c == '0' || c == '1')
	#define IS_HEXA(c)			(IS_NUMBER(c) || (c >= 'A' && c <= 'F'))
	#define IS_ENDLINE(c)		(c == '\n' || c == '\r')
	#define IS_SPACE(c)			(c == ' ' || c == '\t')
	#define IS_SPACEX(c)		(IS_SPACE(c) || IS_ENDLINE(c) || IS_NULL(c))

	#define IS_MULOP(c)			(c == '*' || c == '/' || c == '%')
	#define IS_ADDOP(c)			(c == '+' || c == '-')

	static char *src_buff;
	

    void scanner(char *buff);
    
    int bnf_instruction(void);
    
    int bnf_expression(void);
    int bnf_signed_term(void);
    int bnf_term(void);
    int bnf_factor(void);
    int bnf_addop(void);
    int bnf_mulop(void);
    
    int bnf_id(void);
    
    int bnf_name(void);
    int bnf_capname(void);	// with '_'
    int bnf_lowname(void);	// without '_'
    
	int bnf_string(void);
	
	int bnf_number(void);
	int bnf_decimal(void);
	int bnf_binary(void);
	int bnf_hexadecimal(void);

    int match(char);
    void skip_space(void);

#endif
